Component({
    data: {
        active: 0,
        list: [
            {
                icon: {
                    normal: '../images/category.png',
                    active: '../images/category_click.png',
                },
                text: '社交圈',
                url: '/pages/dynamic/dynamic'
            },
            {
				icon: {
					normal: '../images/message.png',
					active: '../images/message_click.png',
				},
				text: '协助',
				url: '/pages/agency/agency'
			},
			{
				icon: {
					normal: '../images/mine.png',
					active: '../images/mine_click.png',
				},
				text: '我的',
				url: '/pages/mine/mine'
			}
        ]
    },

    methods: {
        onChange(event) {
			this.setData({active: event.detail});
			getApp().globalData.activeIdx = event.detail
            wx.switchTab({
                url: this.data.list[event.detail].url
			});
        },

        init() {
            const page = getCurrentPages().pop();
            this.setData({
                active: this.data.list.findIndex(item => item.url === `/${page.route}`)
            });
        }
    }
});
